package cn.nexd.map.location.collector;

/**
 * CollectorConfig create by codingfish at 15/4/29
 * TODO:
 *
 * @Version V1.0
 */
public class CollectorConfig {

    public boolean wifi_available;
    public boolean bluetooth_available;
    public boolean sensor_available;
    public boolean baseband_available;
    public int collection_mode;
    public int wifi_delay;
    public int bluetooth_delay;
    public int sensor_delay;
    public int collector_delay;
    public int collector_enable_mode;
    public int collector_task_delay;
    public int collector_baseband_delay;
    private CollectorConfig(final Builder builder) {
        this.wifi_available = builder.collector_config_wifi_enable;

        //蓝牙、传感器是否可用的选项只有在主动采集模式下生效。
        if (builder.collector_config_collection_mode == Collector.COLLECTION_MODE_ACTIVE) {
            this.bluetooth_available = builder.collector_config_bluetooth_enable;
            this.sensor_available = builder.collector_config_sensor_enable;
        } else {
            this.bluetooth_available = false;
            this.sensor_available = false;
        }
        this.baseband_available = builder.collector_config_baseband_enable;
        this.collection_mode = builder.collector_config_collection_mode;
        this.bluetooth_delay = builder.collector_config_bluetooth_delay;
        this.sensor_delay = builder.collector_config_sensor_delay;
        this.collector_delay = builder.collector_config_collector_delay;
        this.collector_enable_mode = builder.collector_config_collector_enable_mode;
        this.collector_task_delay = builder.collector_config_wifi_delay_active_mode;
//        this.collector_baseband_delay = builder.collector_config_baseband_delay;
        this.wifi_delay = (collection_mode == Collector.COLLECTION_MODE_PASSIVE ? builder.collector_config_wifi_delay_active_mode : builder.collector_config_wifi_delay_passive_mode);
    }


    public static class Builder {

        /*wifi是否可用，默认 true*/
        private boolean collector_config_wifi_enable = true;
        /*Bluetooth 是否可用，默认 true*/
        private boolean collector_config_bluetooth_enable = true;
        /*采集模式，默认为 COLLECTION_MODE_ACTIVE*/
        private int collector_config_collection_mode = Collector.COLLECTION_MODE_ACTIVE;
        /*Baseband 是否可用， 默认为true*/
        private boolean collector_config_baseband_enable = true;
        /*传感器速率。默认为COLLEction_sensor_DELAY_NORMAL*/
        private int collector_config_sensor_delay = Collector.COLLEction_sensor_DELAY_NORMAL;
        /*Sensor 是否可用。默认 true*/
        private boolean collector_config_sensor_enable = true;
        /*主动模式下的 wifi 采集间隔*/
        private int collector_config_wifi_delay_active_mode = 5 * 1000;
        /*被动模式下的 wifi 采集间隔*/
        private int collector_config_wifi_delay_passive_mode = 5 * 1000;
        /*蓝牙采集间隔*/
        private int collector_config_bluetooth_delay = 5 * 1000;
        /*采集器启动前的延时*/
        private int collector_config_collector_delay = 5 * 1000;
        /*打开采集设计的方式，默认bluetooth_enable_mode_auto*/
        private int collector_config_collector_enable_mode = Collector.bluetooth_enable_mode_auto;


        public Builder setWifiEnable(boolean collector_config_wifi_enable) {
            this.collector_config_wifi_enable = collector_config_wifi_enable;
            return this;
        }

        public Builder setBluetoothEnable(boolean collector_config_bluetooth_enable) {
            this.collector_config_bluetooth_enable = collector_config_bluetooth_enable;
            return this;
        }

        public Builder setBasebandEnable(boolean collector_config_baseband_enable) {
            this.collector_config_baseband_enable = collector_config_baseband_enable;
            return this;
        }

        public Builder setCollectionMode(int collector_config_collection_mode) {
            this.collector_config_collection_mode = collector_config_collection_mode;
            return this;
        }

        public Builder setSensorEnable(boolean collector_config_sensor_enable) {
            this.collector_config_sensor_enable = collector_config_sensor_enable;
            return this;
        }

        public Builder setWifiDelay(int collector_config_wifi_delay_active_mode, int collector_config_wifi_delay_passive_mode) {
            this.collector_config_wifi_delay_active_mode = collector_config_wifi_delay_active_mode;
            this.collector_config_wifi_delay_passive_mode = collector_config_wifi_delay_passive_mode;
            return this;
        }

        public Builder setBluetoothDelay(int collector_config_bluetooth_delay) {
            this.collector_config_bluetooth_delay = collector_config_bluetooth_delay;
            return this;
        }

        public Builder setSensorDelay(int collector_config_sensor_delay) {
            this.collector_config_sensor_delay = collector_config_sensor_delay;
            return this;
        }

        public Builder setCollectorDelay(int collector_config_collector_delay) {
            this.collector_config_collector_delay = collector_config_collector_delay;
            return this;
        }

        public Builder setCollectorEnableMode(int collector_config_collector_enable_mode) {
            this.collector_config_collector_enable_mode = collector_config_collector_enable_mode;
            return this;
        }

        public CollectorConfig build() {
            return new CollectorConfig(this);
        }
    }

}
